package utils

import (
	"strings"
)

func Strstr(haystack string, needle string) string {
	if needle == "" {
		return ""
	}
	idx := strings.Index(haystack, needle)
	if idx == -1 {
		return ""
	}
	return haystack[idx+len([]byte(needle))-1:]
}

// 获取map中最大的值
func GetArrayMax(arr map[string]map[string]interface{}, field string) float64 {
	var number float64
	for _, val := range arr {
		if number < val[field].(float64) {
			number = val[field].(float64)
		}
	}
	return number
}

// 获取map中最小的值
func GetArrayMin(arr map[string]map[string]interface{}, field string) float64 {
	var number float64
	for _, val := range arr {
		//immutable := reflect.ValueOf(val)
		//value := immutable.FieldByName(field).Float()
		if number > val[field].(float64) {
			number = val[field].(float64)
		}
	}
	return number
}
